import React, { Component } from 'react'

export default class Counter extends Component {
  constructor() {
    super()
    this.state = {
      counter: 100
    }
  }
  render() {
    return (
      <div>
        <h1>当前计数为：{this.state.counter}</h1>
        <button onClick={() => this.handleAddCounter()}>+</button>
      </div>
    )
  }

  handleAddCounter() {
    this.setState((state) => {
      return {
        counter: state.counter + 1
      }
    })
  }
}
